package com.chinasoftosg.sicap.utils.taglib;

import java.sql.ResultSet;
import java.util.List;

public class PageResult
{
    
    private int current; // 当前是第几页
    
    private int totalRecord; // 总记录数
    
    private int totalPage; // 总页数
    
    private int pageSize; // 每页显示几条记录
    
    private boolean pre; // 是否有上一页
    
    private boolean next; // 是否有下一页
    
    private String sql; // 执行的查询语句
    
    private ResultSet rs; // 执行的查询语句
    
    private List list; // 检索到的区间数据
    
    public PageResult()
    {
        this.current = 1;
        pageSize = 20;
    }
    
    public int getCurrent()
    {
        return current;
    }
    
    public void setCurrent(int current)
    {
        this.current = current;
    }
    
    public int getTotalRecord()
    {
        return totalRecord;
    }
    
    public void setTotalRecord(int totalRecord)
    {
        this.totalRecord = totalRecord;
        this.getTotalPage();
    }
    
    public int getTotalPage()
    {
        this.totalPage = (totalRecord + pageSize - 1) / pageSize;
        return totalPage;
    }
    
    public void setTotalPage(int totalPage)
    {
        this.totalPage = totalPage;
    }
    
    public int getPageSize()
    {
        return pageSize;
    }
    
    public void setPageSize(int pageSize)
    {
        this.pageSize = pageSize;
    }
    
    public boolean isPre()
    {
        // 如果当前页是第一页，则没有上一页
        this.pre = current > 1 ? true : false;
        return pre;
    }
    
    public void setPre(boolean pre)
    {
        this.pre = pre;
    }
    
    public boolean isNext()
    {
        // 如果当前页是最后一页，则没有下一页
        this.next = current < totalPage ? true : false;
        return next;
    }
    
    public void setNext(boolean next)
    {
        this.next = next;
    }
    
    public String getSql()
    {
        return sql;
    }
    
    public void setSql(String sql)
    {
        this.sql = sql;
    }
    
    public List getList()
    {
        return list;
    }
    
    public void setList(List list)
    {
        this.list = list;
    }
    
    public ResultSet getRs()
    {
        return rs;
    }
    
    public void setRs(ResultSet rs)
    {
        this.rs = rs;
    }
    
}
